﻿
#region Usings

#endregion

namespace LongNet.Util.DataTypes
{
    /// <summary>
    /// Combines three items together
    /// </summary>
    /// <typeparam name="T1">Type for the first item</typeparam>
    /// <typeparam name="T2">Type for the second item</typeparam>
    /// <typeparam name="T3">Type for the third item</typeparam>
    public class Triple<T1, T2, T3>
    {
        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        public Triple()
        {

        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="First">First item</param>
        /// <param name="Second">Second item</param>
        /// <param name="Third">Third item</param>
        public Triple(T1 First, T2 Second, T3 Third)
        {

            this.First = First;
            this.Second = Second;
            this.Third = Third;
        }

        #endregion

        #region Properties

        /// <summary>
        /// First item
        /// </summary>
        public T1 First { get; set; }

        /// <summary>
        /// Second item
        /// </summary>
        public T2 Second { get; set; }

        /// <summary>
        /// Third item
        /// </summary>
        public T3 Third { get; set; }

        #endregion

        #region Public Overridden Properties

        public override int GetHashCode()
        {
            if (First != null && Second != null && Third != null)
            {
                return (First.GetHashCode() ^ Second.GetHashCode()) % Third.GetHashCode();
            }
            return 0;
        }

        public override bool Equals(object obj)
        {
            if (obj != null && obj is Triple<T1, T2, T3>)
            {
                return Equals(First, ((Triple<T1, T2, T3>)obj).First)
                    && Equals(Second, ((Triple<T1, T2, T3>)obj).Second)
                    && Equals(Third, ((Triple<T1, T2, T3>)obj).Third);
            }
            return false;
        }

        #endregion
    }
}